<template>
  <div class="app-container">
    <div class="default-box integral-box">
      <div class="integral-item present">
        <div class="integral-num">111</div>
        <div>当前持有</div>
      </div>
      <div class="integral-item surplus-day">
        <div class="integral-num">11111.1111</div>
        <div>剩余可释放天数</div>
      </div>
      <div class="integral-item surplus-all">
        <div class="integral-num">35379.3566</div>
        <div>剩余可释放积分</div>
      </div>
    </div>
    <div class="default-box">
      <div class="filter-container">
        <el-button class="filter-item" type="primary" icon="el-icon-plus" round>
          新增
        </el-button>
        <el-button class="filter-item" type="primary" icon="el-icon-notebook-2" round plain>
          日志
        </el-button>
      </div>
      <el-table
        :key="tableKey"
        v-loading="listLoading"
        :data="list"
        fit
        highlight-current-row
        style="width: 100%;"
      >
        <el-table-column label="旅行包等级" width="150">
          <template>
            <span>环球旅行包</span>
          </template>
        </el-table-column>
        <el-table-column label="名称" width="200" show-overflow-tooltip>
          <template>
            <span>环球旅行包</span>
          </template>
        </el-table-column>
        <el-table-column label="门槛" width="200">
          <template>
            <el-switch v-model="value1" active-text="否" inactive-text="是" />
          </template>
        </el-table-column>
        <el-table-column label="需要互帮值" width="150">
          <template>
            <span>1000000</span>
          </template>
        </el-table-column>
        <el-table-column label="需要积分" width="150">
          <template>
            <span>1000000</span>
          </template>
        </el-table-column>
        <el-table-column label="返还积分" width="150">
          <template>
            <span>1000000</span>
          </template>
        </el-table-column>
        <el-table-column label="活跃度" width="150">
          <template>
            <span>1000000</span>
          </template>
        </el-table-column>
        <el-table-column label="持有上限" width="150">
          <template>
            <span>1000000</span>
          </template>
        </el-table-column>
        <el-table-column label="释放周期" width="150">
          <template>
            <span>1000000</span>
          </template>
        </el-table-column>
        <el-table-column label="图片" width="150">
          <template>
            <el-image
              style="width: 38px; height: 38px"
              :src="srcurl"
              :preview-src-list="srcList"
            />
          </template>
        </el-table-column>
        <el-table-column label="当前持有" width="150">
          <template>
            <span>无</span>
          </template>
        </el-table-column>
        <el-table-column label="剩余可释放天数" width="150">
          <template>
            <span>1000000</span>
          </template>
        </el-table-column>
        <el-table-column label="剩余可释放积分" width="150">
          <template>
            <span>1000000</span>
          </template>
        </el-table-column>
        <el-table-column label="备忘" width="200">
          <template>
            <span>1</span>
          </template>
        </el-table-column>
        <el-table-column label="状态" width="200">
          <template>
            <el-switch v-model="value1" active-text="禁用" inactive-text="启用" />
          </template>
        </el-table-column>
        <el-table-column label="更新时间" width="200">
          <template>
            <span>2022-05-01 00:00:00</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="150" class-name="small-padding fixed-width">
          <template>
            <i class="el-icon-edit" :style="{color:$store.state.settings.theme}" />
            <i class="el-icon-delete danger-color" />
          </template>
        </el-table-column>
      </el-table>
      <pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>
  </div>
</template>

<script>
import { fetchList } from '@/api/article'
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
export default {
  name: 'Adminrole',
  components: { Pagination },
  data() {
    return {
      tableKey: 0,
      list: null,
      total: 0,
      listLoading: true,
      listQuery: {
        page: 1,
        limit: 10,
        importance: undefined,
        title: undefined,
        type: undefined,
        sort: '+id'
      },
      srcurl: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
      srcList: [
        'https://fuss10.elemecdn.com/8/27/f01c15bb73e1ef3793e64e6b7bbccjpeg.jpeg',
        'https://fuss10.elemecdn.com/1/8e/aeffeb4de74e2fde4bd74fc7b4486jpeg.jpeg'
      ],
      value1: false
    }
  },
  created() {
    this.getList()
  },
  methods: {
    getList() {
      this.listLoading = true
      fetchList(this.listQuery).then(response => {
        this.list = response.data.items
        this.total = response.data.total
        setTimeout(() => {
          this.listLoading = false
        }, 1.5 * 1000)
      })
    }
  }
}
</script>
<style scoped lang="scss">
  [class^=el-icon-], [class*=" el-icon-"]{
    font-size: 16px;
  }
  .small-padding i{
    margin-right: 12px;
  }
  .small-padding i:last-child{
    margin-right: 0px;
  }
  ::v-deep .filter-container .el-input--medium .el-input__inner{
    width: 240px;
  }
  .integral-box{
    display: flex;
    justify-content: space-between;
    align-items: center;
    .integral-item{
      border-radius: 16px;
      width: 30%;
      text-align: center;
      padding: 50px 16px;
      .integral-num{
        font-size: 20px;
        font-weight: 700;
        padding-bottom: 10px;
      }
      &.present{
        background: linear-gradient(180deg, #F5FEF2 0%, #E6FEEE 100%);
        color: #2CAB40;
      }
      &.surplus-day{
        background: linear-gradient(180deg, #F2F9FE 0%, #E6F4FE 100%);
        color: #165DFF;
      }
      &.surplus-all{
        background: linear-gradient(180deg, #F6F7FF 0%, #ECECFF 100%);
        color: #8D4EDA;
      }
    }
  }
</style>
